package com.dkd.easybook.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dkd.common.annotation.Log;
import com.dkd.common.core.controller.BaseController;
import com.dkd.common.core.domain.AjaxResult;
import com.dkd.common.enums.BusinessType;
import com.dkd.easybook.domain.EbNoteCategoryDefault;
import com.dkd.easybook.service.IEbNoteCategoryDefaultService;
import com.dkd.common.utils.poi.ExcelUtil;
import com.dkd.common.core.page.TableDataInfo;

/**
 * 笔记默认类别Controller
 *
 * @author itheima
 * @date 2024-12-13
 */
@Api(tags = "笔记默认类别Controller")
@RestController
@RequestMapping("/easybook/sysNoteCat")
public class EbNoteCategoryDefaultController extends BaseController
{
    @Autowired
    private IEbNoteCategoryDefaultService ebNoteCategoryDefaultService;

    /**
     * 查询笔记默认类别列表
     */
    @ApiOperation("查询笔记默认类别列表")
    @PreAuthorize("@ss.hasPermi('easybook:sysNoteCat:list')")
    @GetMapping("/list")
    public TableDataInfo list(EbNoteCategoryDefault ebNoteCategoryDefault)
    {
        startPage();
        List<EbNoteCategoryDefault> list = ebNoteCategoryDefaultService.selectEbNoteCategoryDefaultList(ebNoteCategoryDefault);
        return getDataTable(list);
    }

    /**
     * 导出笔记默认类别列表
     */
    @ApiOperation("导出笔记默认类别列表")
    @PreAuthorize("@ss.hasPermi('easybook:sysNoteCat:export')")
    @Log(title = "笔记默认类别", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EbNoteCategoryDefault ebNoteCategoryDefault)
    {
        List<EbNoteCategoryDefault> list = ebNoteCategoryDefaultService.selectEbNoteCategoryDefaultList(ebNoteCategoryDefault);
        ExcelUtil<EbNoteCategoryDefault> util = new ExcelUtil<EbNoteCategoryDefault>(EbNoteCategoryDefault.class);
        util.exportExcel(response, list, "笔记默认类别数据");
    }

    /**
     * 获取笔记默认类别详细信息
     */
    @ApiOperation("获取笔记默认类别详细信息")
    @PreAuthorize("@ss.hasPermi('easybook:sysNoteCat:query')")
    @GetMapping(value = "/{categoryId}")
    public AjaxResult getInfo(@PathVariable("categoryId") Long categoryId)
    {
        return success(ebNoteCategoryDefaultService.selectEbNoteCategoryDefaultByCategoryId(categoryId));
    }

    /**
     * 新增笔记默认类别
     */
    @ApiOperation("新增笔记默认类别")
    @PreAuthorize("@ss.hasPermi('easybook:sysNoteCat:add')")
    @Log(title = "笔记默认类别", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EbNoteCategoryDefault ebNoteCategoryDefault)
    {
        return toAjax(ebNoteCategoryDefaultService.insertEbNoteCategoryDefault(ebNoteCategoryDefault));
    }

    /**
     * 修改笔记默认类别
     */
    @ApiOperation("修改笔记默认类别")
    @PreAuthorize("@ss.hasPermi('easybook:sysNoteCat:edit')")
    @Log(title = "笔记默认类别", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EbNoteCategoryDefault ebNoteCategoryDefault)
    {
        return toAjax(ebNoteCategoryDefaultService.updateEbNoteCategoryDefault(ebNoteCategoryDefault));
    }

    /**
     * 删除笔记默认类别
     */
    @ApiOperation("删除改笔记默认类别")
    @PreAuthorize("@ss.hasPermi('easybook:sysNoteCat:remove')")
    @Log(title = "笔记默认类别", businessType = BusinessType.DELETE)
	@DeleteMapping("/{categoryIds}")
    public AjaxResult remove(@PathVariable Long[] categoryIds)
    {
        return toAjax(ebNoteCategoryDefaultService.deleteEbNoteCategoryDefaultByCategoryIds(categoryIds));
    }
}
